#include <rtcArg.h>
#include <pbase.h>

rtcOptParmIn rtcArgInput = {0};

static argParseStc rtcArgMap[] = 
{
    FACTORY_ARG_PS_COM("read", 'r', "read date from rtc, like: sudo ./builddir/test -r -f /dev/rtc0 -c /tmp/tmzonesave", no_argument, ARG_TYPE_I, sizeof(rtcArgInput.read), &rtcArgInput.read),
    FACTORY_ARG_PS_COM("write", 'w', "write date to rtc, like: sudo ./builddir/test -w \"2024-09-14 13:33:00\" -f /dev/rtc0 -c /tmp/tmzonesave -z 8", required_argument, ARG_TYPE_STR, sizeof(rtcArgInput.write), &rtcArgInput.write),
    FACTORY_ARG_PS_COM("optzone", 'o', "set date time zone, like: sudo ./builddir/test -o 8 -f /dev/rtc0 -c /tmp/tmzonesave", required_argument, ARG_TYPE_I, sizeof(rtcArgInput.optzone), &rtcArgInput.optzone),
    FACTORY_ARG_PS_COM("rtcfile", 'f', "config rtc dev file, like: -f /dev/rtc0", required_argument, ARG_TYPE_STR, sizeof(rtcArgInput.rtcfile), &rtcArgInput.rtcfile),
    FACTORY_ARG_PS_COM("zonefile", 'c', "config rtc zone file, like: -c /tmp/tmzone", required_argument, ARG_TYPE_STR, sizeof(rtcArgInput.zonefile), &rtcArgInput.zonefile),
    FACTORY_ARG_PS_COM("help", 'h', "print opt list help, like: -h", no_argument, ARG_TYPE_I, sizeof(rtcArgInput.help), &rtcArgInput.help),
    FACTORY_ARG_PS_COM("zone", 'z', "date time zone", required_argument, ARG_TYPE_I, sizeof(rtcArgInput.zone), &rtcArgInput.zone),

    FACTORY_ARG_PS_COM("schk", 's', "check short", required_argument, ARG_TYPE_SH, sizeof(rtcArgInput.schk), &rtcArgInput.schk),
    FACTORY_ARG_PS_COM("cchk", 'i', "check int, like ./builddir/test -i1234", optional_argument, ARG_TYPE_C, sizeof(rtcArgInput.cchk), &rtcArgInput.cchk),
    FACTORY_ARG_PS_COM("fchk", 't', "check float", optional_argument, ARG_TYPE_F, sizeof(rtcArgInput.fchk), &rtcArgInput.fchk),
    FACTORY_ARG_PS_COM("dchk", 'd', "check double", optional_argument, ARG_TYPE_D, sizeof(rtcArgInput.dchk), &rtcArgInput.dchk),
    FACTORY_ARG_PS_COM("lchk", 'l', "check long long", optional_argument, ARG_TYPE_LL, sizeof(rtcArgInput.lchk), &rtcArgInput.lchk),
};
static argBuffStc rtcArgBuff = {ARRAY_LEN(rtcArgMap), rtcArgMap};

int rtcParseInArg(int argc, char **argv)
{
    memset(&rtcArgInput, 0, sizeof(rtcArgInput));
    rtcArgInput.zone = 100;
    rtcArgInput.optzone = 100;
    return parseArgCom(argc, argv, &rtcArgBuff);
}

int printfRtcArgs()
{
    return printOptArgInfo(&rtcArgBuff);
}